package demoMod.invincibleOne.cards.invincible;

import basemod.helpers.CardModifierManager;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.utility.SFXAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import demoMod.invincibleOne.InvincibleOneMod;
import demoMod.invincibleOne.enums.CardTagsEnum;
import demoMod.invincibleOne.interfaces.OnRestHook;
import demoMod.invincibleOne.modifiers.ExhaustAtStartOfCombatMod;

public class Insomnia extends AbstractInvincibleCard implements OnRestHook {
    public static final String ID = InvincibleOneMod.makeID("Insomnia");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/Insomnia.png";

    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = CardRarity.UNCOMMON;
    private static final CardTarget TARGET = CardTarget.NONE;

    private static final int COST = -2;

    public Insomnia() {
        super(ID, NAME, InvincibleOneMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.modifier = new ExhaustAtStartOfCombatMod();
        CardModifierManager.addModifier(this, modifier);
        this.tags.add(CardTagsEnum.ALERT);
        this.baseMagicNumber = this.magicNumber = 8;
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> {
            upgradeMagicNumber(2);
            this.rawDescription = cardStrings.UPGRADE_DESCRIPTION;
            this.initializeDescription();
        };
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {

    }

    @Override
    public void onRest() {
        InvincibleOneMod.addToBot(new SFXAction("DEBUFF_1"));
        InvincibleOneMod.addToBot(new AbstractGameAction() {
            @Override
            public void update() {
                AbstractDungeon.player.damage(new DamageInfo(null, magicNumber));
                if (!upgraded) {
                    upgrade();
                }
                isDone = true;
            }
        });
    }
}
